#!/bin/bash
set -e

usage () {
    echo "USAGE: mapscript-to-env path-to-env"
    exit -1
}

if [ ! -d "$1" ]; then usage; fi

SRC=`/usr/bin/python -c "import mapscript, os.path; print os.path.split(mapscript.__file__)[0]"`
DST=`$1/bin/python -c "import sys; print sys.path[-1]"`

cp -vu $SRC/mapscript.py $DST
cp -vu $SRC/_mapscript.so $DST || cp -vu $SRC/_mapscript.x86_64-linux-gnu.so $DST